/* ====================================================================
 * Copyright (C) 2012 - Deniz Sezen
 * ====================================================================
 * File: dx_util.h
 * Purpose: Useful functions for interacting with the stack inside
 *  function hooks.
 * ====================================================================
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _DX_UTIL_H
#define _DX_UTIL_H

// =======================================================================
// Reads an argument out of ESP.
// TODO: Fix this to work with non-atomic data types.
// =======================================================================
template<class T> 
T ReadArg( void* addr )
{
	return *((T *)(addr));
}

// =======================================================================
// Places an argument back into the stack.
// TODO: Fix this to work with non-atomic data types.
// =======================================================================
template<class T>
void SetArg( void* addr, T value )
{
	*((T *)addr) = value;
}

#endif